<?php
if($form_ja->is_valid($_POST)){

              list($nom, $prenom, $adresse, $cp, $ville, $tel, $email, $du, $cg) = $form_ja->get_cleaned_data('nom', 'prenom','adresse', 'cp', 'ville', 'tel', 'email', 'du','cg');
          
            $result = save_bdd($nom, $prenom, $adresse, $cp, $ville, $tel, $email, $du, $cg);
            
            $_SESSION['nom'] = $nom;
            $_SESSION['prenom'] = $prenom;
            $_SESSION['email'] = $email;
            
            $foo = new Upload($_FILES['fichier']);
            
              if($result){

                  if ($foo->uploaded) {
                      // save uploaded image with no changes
                      echo getcwd();
                      
                      $foo->Process("wp-content\uploads\ja");              
                      
                      if ($foo->processed) {
                        // everything was fine !
                        echo '<p class="result">';
                        echo '  <b>File uploaded with success</b><br />';
                        echo   $dir_pics.$foo->file_dst_name.$foo->file_dst_name;
                        echo '   (' . round(filesize($foo->file_dst_pathname)/256)/4 . 'KB)';
                        echo '</p>';  
                        echo 'original image copied';
                        
                        // mail à l'admin
                        
                        $headers = "Reply-To : contact@tousartistes.fr\n";
                        $headers = "From: tousarbitres<contact@tousartistes.fr>\n";
                        
                        //$headers .= "Content-type: text/html; charset=ISO-8859-1\n";
                        $headers .= "Content-Type: text/html; charset=\"iso-8859-1\"";
                        $body="<font color='#000000;' face='Century Gothic, Gill sans MT,Verdana' size='2'>";
                        
                        $body.="Une nouvelle photo a &eacute;t&eacute; envoy&eacute;e sur tousarbitres.fr .<br>";
                        $body.="<a href='http://tousartistes.fr/wp-admin'>";
                        $body.="http://tousartistes.fr/wp-admin";
                        $body.="</a>";
                        $body.="<br><br>";
                        $body.="</font>";
                        $obj="Nouvelle photo envoyée sur Tousartistes";
                        
                        $dest = 'ng@saya-editions.fr';
                        mail($dest,$obj,$body,$headers);
                        
                        // mail à l'arbitre
                        
                        $headers = "Reply-To : contact@tousartistes.fr\n";
                        $headers = "From: tousarbitres<contact@tousarbitres.fr>\n";
                        
                        //$headers .= "Content-type: text/html; charset=ISO-8859-1\n";
                        $headers .= "Content-Type: text/html; charset=\"iso-8859-1\"";
                        $body="<font color='#000000;' face='Century Gothic, Gill sans MT,Verdana' size='2'>";
                        
                        $body.="Votre photo a &eacute;t&eacute; envoy&eacute;e sur tousarbitres.fr .<br>";
                        $body.="<a href='http://tousartistes.fr/wp-admin'>";
                        $body.="http://tousartistes.fr/wp-admin";
                        $body.="</a>";
                        $body.="<br><br>";
                        $body.="</font>";
                        $obj="Photo envoyée sur tousarbitres";
                        
                        $dest = 'ng@saya-editions.fr';
                        mail($email,$obj,$body,$headers); 
                        ?>   
                            <script type='text/javascript'>
                              window.location="?page_id=3107";
                            </script>                                         
                           <?php                                           
                      } 
                      else {
                        echo 'error : ' . $foo->error;
                      }
                          
                  }

              
            }
        
        }
?>